package com.jason.quectel.activities;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;

import com.jason.quectel.R;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

public class DialogTestActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog_test);
    }

    public void showDialog(View view) {
        String[] items = {"安徽省", "广西省", "湖南省", "湖北省"};
        boolean[] choose = {true, false, false, false};
        new AlertDialog.Builder(this).setTitle("标题")
                //自定义布局
                //.setView(R.layout.dialog_show)
                //单选对话框
                //.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {
                //    @Override
                //    public void onClick(DialogInterface dialog, int which) {
                //        Toast.makeText(DialogTestActivity.this, items[which] + "被选中", Toast.LENGTH_SHORT).show();
                //    }
                //})

                //多选对话框
                //.setMultiChoiceItems(items, choose, new DialogInterface.OnMultiChoiceClickListener() {
                //    @Override
                //    public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                //        Toast.makeText(DialogTestActivity.this, items[which] + (isChecked ? "被选中" : "取消选中"), Toast.LENGTH_SHORT).show();
                //    }
                //})

                //选择对话框
                //.setItems(items, new DialogInterface.OnClickListener() {
                //    @Override
                //    public void onClick(DialogInterface dialog, int which) {
                //        Toast.makeText(DialogTestActivity.this, items[which], Toast.LENGTH_SHORT).show();
                //    }
                //})
                .setMessage("你看我帅吗？")
                .setPositiveButton("必须帅", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .setNegativeButton("不帅", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .setNeutralButton("还行", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .setIcon(R.mipmap.ic_launcher)
                .create().show();
    }
}